﻿<%@ Page Language="C#" MasterPageFile="~/Layout.Master" AutoEventWireup="true" CodeBehind="busyRooms.aspx.cs" Inherits="PT.WebForm4" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="cpContent" ContentPlaceHolderID="cpContent" runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
        EmptyDataText="Nie ma aktualnie zajętch pokoi." Height="100%" 
        Width="100%" AllowPaging="True" CssClass="grid" BorderStyle="None" 
        DataKeyNames="id">
        <Columns>
            <asp:BoundField DataField="name" HeaderText="Nazwa" 
                SortExpression="name" >
            </asp:BoundField>
            <asp:BoundField DataField="startDate" HeaderText="Początek" 
                SortExpression="startDate" >
            </asp:BoundField>
            <asp:BoundField DataField="endDate" HeaderText="Koniec" 
                SortExpression="endDate" >
            </asp:BoundField>
            <asp:BoundField DataField="bookerName" HeaderText="Rezerwujący" 
                SortExpression="bookerName" >
            </asp:BoundField>
            <asp:BoundField DataField="telephone" HeaderText="Telefon" 
                SortExpression="telephone" />
            <asp:HyperLinkField DataNavigateUrlFields="id" 
                DataNavigateUrlFormatString="editReservation.aspx?id={0}" 
                HeaderText="Rezerwacja" NavigateUrl="editReservation.aspx" Text="Edytuj" />
            <asp:CommandField HeaderText="Rezerwacja" ShowDeleteButton="True" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:HotelConnectionString2 %>" 
        ProviderName="<%$ ConnectionStrings:HotelConnectionString2.ProviderName %>"
        SelectCommand="SELECT res.id, res.startDate, res.endDate, res.bookerName, res.telephone, res.room_id, roo.name FROM Reservation AS res INNER JOIN Rooms AS roo ON res.room_id = roo.id WHERE     (res.startDate < GETDATE())"
        DeleteCommand="DELETE FROM [Reservation] WHERE [id] = @original_id" 
        ConflictDetection="CompareAllValues" 
        InsertCommand="INSERT INTO [Reservation] ([startDate], [endDate]) VALUES (@startDate, @endDate)" 
        OldValuesParameterFormatString="original_{0}" 
        UpdateCommand="UPDATE [Reservation] SET [startDate] = @startDate, [endDate] = @endDate WHERE [id] = @original_id AND [startDate] = @original_startDate AND [endDate] = @original_endDate">
        <DeleteParameters>
            <asp:Parameter Name="original_id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter DbType="Date" Name="startDate" />
            <asp:Parameter DbType="Date" Name="endDate" />
            <asp:Parameter Name="original_id" Type="Int32" />
            <asp:Parameter DbType="Date" Name="original_startDate" />
            <asp:Parameter DbType="Date" Name="original_endDate" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter DbType="Date" Name="startDate" />
            <asp:Parameter DbType="Date" Name="endDate" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>
